<template>
  <div class="visitor-toVisit">
    <div class="search-group">
      <div class="input-wrap">
        <div class="label">上报人姓名:</div>
        <div class="input-item">
          <a-input :maxLength="30" clearable v-model="queryParam.miniUserName" placeholder="请输入姓名" />
        </div>
      </div>

      <div class="input-wrap">
        <div class="label">联系电话:</div>
        <div class="input-item">
          <a-input :maxLength="30" clearable v-model="queryParam.miniUserMobile" placeholder="请输入联系电话" />
        </div>
      </div>

      <div class="input-wrap">
        <div class="label">提交时间:</div>
        <div class="time-item">
          <start-end-time
            :times="times"
            :showTime="{ format: 'HH:mm:ss' }"
            format="YYYY-MM-DD HH:mm:ss"
            @timeChange="timeChange"
            :resetTime="resetTime"
          ></start-end-time>
        </div>
      </div>

      <div class="btn-wrap">
        <a-button class="searchBtn" @click="searchQuery(queryParam.startTime, queryParam.endTime)" type="primary">
          搜索
        </a-button>
        <a-button class="resetBtn" @click="searchReset()" type="primary"> 重置 </a-button>
      </div>
    </div>

    <div>
      <a-table
        rowKey="id"
        class="tableList"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        @change="handleTableChange"
      >
        <template v-slot:action="records">
          <span class="operation deatil-color" @click="detailHandle(records)">详情 </span>
        </template>
      </a-table>
    </div>
    <detail-modal ref="detailModal"></detail-modal>
  </div>
</template>
<script>
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { mapState } from 'vuex'
import detailModal from '../modules/detailModal'
import startEndTime from '@/components/startEndTime'
export default {
  name: 'visitor-toVisit',
  components: { detailModal, startEndTime },
  mixins: [JeecgListMixin],
  computed: {
    ...mapState({
      isPoliceAgencyId: (state) => state.user.isPoliceAgencyId,
    }),
  },
  watch: {
    isPoliceAgencyId(v) {
      this.queryParam.policeAgencyId = v.id ? v.id : ''
      this.searchQuery()
    },
  },
  data() {
    return {
      url: {
        list: 'common/clue_reporting/page?status=1',
        tree: true,
      },
      columns: [
        {
          title: '序号',
          align: 'center',
          width: 100,
          customRender: function (t, r, index) {
            return parseInt(index) + 1
          },
        },
        {
          title: '线索名称',
          dataIndex: 'clueTitle',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '地点',
          dataIndex: 'discoverySite',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '上报人姓名',
          dataIndex: 'miniUserName',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '联系电话',
          dataIndex: 'miniUserMobile',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '提交时间',
          dataIndex: 'createTime',
          ellipsis: true,
          align: 'center',
        },
        {
          title: '操作',
          scopedSlots: { customRender: 'action' },
          align: 'center',
        },
      ],
    }
  },
  mounted() {},

  methods: {
    timeChange(v, index) {
      if (index == 1) {
        this.queryParam.startTime = this.$moment(v).valueOf()
      } else {
        this.queryParam.endTime = this.$moment(v).valueOf()
      }
      if (v == null) {
        this.queryParam.startTime = null
        this.queryParam.endTime = null
      }
    },

    detailHandle(records) {
      records = { status: 1, ...records }
      this.$refs.detailModal.show(records)
    },
  },
}
</script>
